//职位管理有内容
import React, {Component} from 'react'
import {
    View,
    Text,
    TouchableOpacity,
} from 'react-native';


import {Managelist_Style as styles} from '../../../../styles';
import sal from '../../../util/sal';
import {fetchRequest} from "../../../util/fetch";

let Dimensions = require('Dimensions');
let width = Dimensions.get('window').width;

export default class Manage_list extends Component {
    constructor(props) {
        super(props);
        this.state = {
            count: 0,
        };
        this.noReadCount();
    }

    render() {
        return (
            <View style={styles.man_all}>

                <TouchableOpacity style={styles.man_top} activeOpacity={1}
                                  onPress={() => {
                                      this.props.navigation.navigate('Cdetailpos_all',
                                          {
                                              postionId: this.props.postion.postionId,
                                              deleteRow: this.props.deleteRow
                                          })
                                  }}>
                    <View style={styles.man_eveone}>
                        <View style={styles.man_onein}>
                            <Text style={styles.man_pos}>{this.props.postion.postionName}</Text>
                            <Text
                                style={styles.man_over}>{this._postionWelfare(this.props.postion.postionWelfare)}
                            </Text>
                        </View>
                        <Text
                            style={styles.man_money}>{sal(this.props.postion.postionMm, this.props.postion.postionYm)}
                        </Text>
                    </View>

                    <View style={styles.man_evetwo}>
                        <Text style={styles.man_area}>{this.props.postion.postionSpace}</Text>
                        <Text style={styles.man_area}>{this.props.postion.postionExp}工作经验</Text>
                        <Text style={styles.man_area}>{this.props.postion.postionEducation}</Text>
                    </View>
                </TouchableOpacity>

                <View style={styles.man_bottom}>
                    <TouchableOpacity style={[styles.man_left, {width: width * 0.5}]} activeOpacity={1}
                                      onPress={() => {
                                          this.props.navigation.navigate('Cbrowse', {postion: this.props.postion})
                                      }}>
                        <View>
                            <Text style={styles.man_numtext}>浏览人数</Text>
                            <Text style={styles.man_num1}>{this.state.count}</Text>
                        </View>
                    </TouchableOpacity>

                    <TouchableOpacity style={[styles.man_right, {width: width * 0.5}]} activeOpacity={1}
                                      onPress={() => {
                                          this.props.navigation.navigate('Cdeliver', {postion: this.props.postion})
                                      }}>
                        <View>
                            <Text style={styles.man_numtext}>投递人数</Text>
                            {
                                this.props.postion.sees === 0 ?
                                    <Text style={styles.man_num2}>( {this.props.postion.total} )</Text>
                                    : <Text style={styles.man_num1}>{this.props.postion.sees}</Text>
                            }
                        </View>
                    </TouchableOpacity>
                </View>
            </View>
        )
    }

    _postionWelfare(a) {
        let welfare = '';
        if (a == 1) {
            welfare = '审核中';
        } else if (a == 2) {
            welfare = '审核未通过';
        } else if (a == 3) {
            welfare = '正在招聘';
        } else if (a == 4) {
            welfare = '已暂停';
        } else if (a == 5) {
            welfare = '已结束';
        }
        return welfare;
    }

    noReadCount() {
        fetchRequest('Postion/selPosBrowseNum.go', 'POST', {postionId: this.props.postion.postionId}).then(
            res => this.setState({count: res.count})
        );
    }

}